package andy.ham;

/**
 * Created by 王汉玺 on 2018/6/17.
 */
        import android.app.Activity;
        import android.content.Intent;
        import android.os.Bundle;
        import android.util.Base64;
        import android.util.Log;
        import android.view.View;
        import android.widget.Button;
        import android.widget.EditText;
        import android.widget.TextView;
        import android.widget.Toast;
        import andy.ham.LoginActivity;
        import andy.ham.R;
        import org.json.JSONObject;
        import java.util.concurrent.TimeUnit;


public class LoginActivity extends Activity implements View.OnClickListener {
    private static final String TAG = "login";
    Button loginBtn = null;
    EditText useridEt = null;
    EditText passEt = null;
    TextView promptText = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout);
        loginBtn = (Button) findViewById(R.id.loginBtn);
        loginBtn.setOnClickListener(this);
        useridEt = (EditText) findViewById(R.id.userId);
        passEt = (EditText) findViewById(R.id.pass);
        promptText = (TextView) findViewById(R.id.promptText);

    }


    @Override
    public void onClick(View v) {
        String userid = useridEt.getText().toString().trim();
        String pass = passEt.getText().toString().trim();
        if(userid.equals("")){
            promptText.setText(R.string.userIdError);
            return ;
        }
        if(pass.equals("")){
            promptText.setText(R.string.passError);
            return ;
        }


        if (userid.equals("1") && pass.equals("1")) {
            Toast.makeText(this,"登陆成功", Toast.LENGTH_LONG).show();
            //Intent LoginActivity = new Intent(this,LifeDiary.class);
            //startActivity(LoginActivity);
            //LoginActivity.this.finish();

            Intent intent = new Intent();
            intent.setClass(LoginActivity.this,LifeDiary.class);
            LoginActivity.this.startActivity(intent);
        } else {
            Toast.makeText(this,"密码错误，请重试", Toast.LENGTH_LONG).show();
        }

    }
}
